<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="C:\Users\Administrator\Desktop\font_bv4lzxr8bl6\demo.css">
    <link rel="stylesheet" href="C:\Users\Administrator\Desktop\font_bv4lzxr8bl6\iconfont.css">
    <style>
        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        li{
            list-style-type: none;
            /* color: red; */
        }
        a{
            text-decoration: none;
          
        }
        .box{
            width: 600px;
            height: 400px;
            margin: 100px auto;
            overflow: hidden;
            position: relative;
        }
        ul{
            display: flex;
            position: absolute;
        }
        img{
            width: 600px;
            height: 400px;
        }
        .left,.right{
            /* width: 40px;
            height: 40px; */
            /* background-color: rgba(0,0,0,0.4); */
            font-size: 30px;
            /* color: red; */
            text-align: center;
            line-height: 40px;
            position: absolute;
            top: 180px;
            display: none;
        }
        .left{
            left: 10px;
        }
        .right{
            right: 10px;
        }
        ol{
            position: absolute;
            bottom: 20px;
            left: 250px;
            display: flex;
        }
        ol li{
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background-color: white;
            margin-right: 10px;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li><img src="./1.png" alt=""></li>
            <li><img src="./2.png" alt=""></li>
            <li><img src="./3.png" alt=""></li>
            <li><img src="./5.jpg" alt=""></li>
            <li><img src="./6.jpg" alt=""></li>
        </ul>
        <span class="left iconfont icon-zuojiantou-"></span>
        <span class="right iconfont icon-youjiantou"></span>
        <ol>
            <li style="background-color: red;" index="0"></li>
            <li index="1"></li>
            <li index="2"></li>
            <li index="3"></li>
            <li index="4"></li>
        </ol>
    </div>
</body>
</html>
<script>
    var left = document.querySelector('.left')
    var right = document.querySelector('.right')
    var box = document.querySelector('.box')
    var ul = document.querySelector('ul')
    box.onmouseenter = function(){
        left.style.display='block'
        right.style.display='block'
        clearInterval(time)
    }
    box.onmouseleave = function(){
        left.style.display='none'
        right.style.display='none'
        autoUl()
    }
    var num = 0;
    right.onclick = function(){
        num++;
        if(num==5){
            num=0
        }
        ul.style.left=(-600*num)+'px';
        change(num)
    }
    left.onclick = function(){
        num--;
        if(num<0){
            num=4
        }
        ul.style.left=-(600*num)+'px'
        change(num)
    }
    var time;
    function autoUl(){
        time = setInterval(function(){
            right.onclick()
        },1000)
    }
    autoUl()
    var yq = document.querySelectorAll('ol li')
    for(var i=0;i<yq.length;i++){
        yq[i].onclick = function(){
            for(var i=0;i<yq.length;i++){
                yq[i].style.backgroundColor = 'white'
            }
            this.style.backgroundColor = 'red'
            var index = this.getAttribute('index');
            num = index;
            ul.style.left = (-600*index)+'px'
        }
    }
    function change(index){
        for(var i=0;i<yq.length;i++){
            yq[i].style.backgroundColor='white'
        }
        yq[index].style.backgroundColor='red'
    }
</script>